//
//  LCContentTableViewCell.m
//  段子手
//
//  Created by dllo on 16/3/18.
//  Copyright © 2016年 JokesTeam. All rights reserved.
//

#import "LCContentTableViewCell.h"

@interface LCContentTableViewCell ()

@property (nonatomic, retain) UIImageView *imgVUserC;
@property (nonatomic, retain) UILabel  *labelUserNameC;
@property (nonatomic, retain) UILabel *labelCommentText;
@property (nonatomic, retain) UIButton *buttonZanC;
@property (nonatomic, retain) UILabel *labelZanC;

/**
 *  评论内容的自适应高度
 */
@property (nonatomic, assign) CGRect rectCommentText;

@end


@implementation LCContentTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self create];
    }
    return self;
}


- (void)setModel:(LCHomeCommentModel *)model{
    
    _model = model;
    
    [self setModelValue];
    
    
}

- (void)setModelValue{
    
    self.rectCommentText = [WxlAPPTools scripeSuitWidthWithString:_model.text Font:13 Size:CGSizeMake(self.contentView.frame.size.width - _labelUserNameC.frame.origin.x - 10, 0)];
    
    
    [_imgVUserC sd_setImageWithURL:[NSURL URLWithString:_model.avatar_url]];
    
    _labelCommentText.text = _model.text;
    
    _labelUserNameC.text = _model.user_name;
    
    _labelZanC.text = [NSString stringWithFormat:@"%@", _model.digg_count];
    
    
    NSLog(@"%@", _model.text);
    
}



- (void)create{
    self.imgVUserC = [[UIImageView alloc]init];
    [self.contentView addSubview: _imgVUserC];
    
    self.labelUserNameC = [[UILabel alloc]init];
    [self.contentView addSubview:_labelUserNameC];
    
    
    self.labelCommentText = [[UILabel alloc]init];
    [self.contentView addSubview: _labelCommentText];
    
    
    self.labelZanC = [[UILabel alloc]init];
    [self.contentView addSubview: _labelZanC];
    
    
    self.buttonZanC = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.contentView addSubview:_buttonZanC];
    
    
    


}


- (void)layoutSubviews{
    
    _imgVUserC.frame = CGRectMake(10, 15, 30, 30);
    _imgVUserC.layer.cornerRadius = 15;
    _imgVUserC.layer.masksToBounds = YES;
//    _imgVUserC.backgroundColor = [UIColor blackColor];
    

    
    _labelZanC.frame = CGRectMake(self.contentView.frame.size.width - 60, _imgVUserC.frame.origin.y, 50, 15);
    _labelZanC.font = [UIFont systemFontOfSize:12];
    
    _buttonZanC.frame = CGRectMake(self.contentView.frame.size.width - 60 - 10 - 30, _imgVUserC.frame.origin.y - 10, 30, 30);
    [_buttonZanC setImage:[UIImage imageNamed:@"RC32NLI__LBBJR]ET5I%D{5.jpg"] forState:UIControlStateNormal];
    
        _labelUserNameC.frame = CGRectMake(_imgVUserC.frame.origin.x + _imgVUserC.frame.size.width + 10, _imgVUserC.frame.origin.y, self.contentView.frame.size.width - 50 - 95, 15);
    _labelUserNameC.font = [UIFont systemFontOfSize:12];
    _labelUserNameC.textColor = [UIColor grayColor];
    
//    评论内容
    _labelCommentText.frame = CGRectMake(_labelUserNameC.frame.origin.x, _labelUserNameC.frame.origin.y + _labelUserNameC.frame.size.height + 10, self.contentView.frame.size.width - _labelUserNameC.frame.origin.x - 10, _rectCommentText.size.height);
    _labelCommentText.numberOfLines = 100;
    _labelCommentText.font = [UIFont systemFontOfSize:13];
    
//    _labelCommentText.backgroundColor = [UIColor blackColor];
    
    
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
